{smcl}
{txt}{sf}{ul off}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}\\micro.intra\Projekt\P0624$\P0624_Gem\Kitschelt\submission\precinct_vote.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}16 Jan 2024, 11:35:16
{txt}
{com}. clear
{txt}
{com}. *Open data with precinct id
. use "dist p_id year update.dta", clear
{txt}
{com}. keep p_id year llkk dist
{txt}
{com}. keep if year==2010 |year==2006
{txt}(14,670,894 observations deleted)

{com}. 
. *Add main data with indices
. joinby p_id year using main_data, unmatched(none)
{txt}
{com}. gen woman=Kon==2
{txt}
{com}. keep  x y   galtan_pct  education woman stdoffshore_pct sector cap_exec_alt dist llkk year
{txt}
{com}. drop if year <2006
{txt}(0 observations deleted)

{com}. drop if x==. |y==.
{txt}(0 observations deleted)

{com}. *Collapse data to precinct levenl
. collapse  (mean) x y galtan_pct  education woman stdoffshore_pct sector cap_exec_alt , by( dist llkk year)
{res}{txt}
{com}. *Add election results
.  joinby dist llkk year using "dist_election_02_14" , unmatched(none) 
{txt}
{com}. 
.  foreach var in x y {c -(}
{txt}  2{com}.         binscatter vsr_b `var', nq(100) scheme(s1mono) mcolor(dkorange) msymbol(smcircle) ///
>                 ylabel(, angle(horizontal) grid) ytitle(Vote Share Sweden Dem.)
{txt}  3{com}.         graph save    vsr_b_`var', replace
{txt}  4{com}.         binscatter vsr_s `var', nq(100) scheme(s1mono) mcolor(cranberry) msymbol(smcircle)  ///
>                 ylabel(, angle(horizontal) grid)   ytitle(Vote Share Social Dem.)
{txt}  5{com}.         graph save    vsr_s_`var' , replace
{txt}  6{com}.         binscatter vsr_g `var', nq(100) scheme(s1mono) mcolor(forest_green)  msymbol(smcircle)  ///
>                 ylabel(, angle(horizontal) grid)   ytitle(Vote Share Green Party)
{txt}  7{com}.         graph save    vsr_g_`var' , replace
{txt}  8{com}.         binscatter vsr_m `var', nq(100) scheme(s1mono) mcolor(navy)  msymbol(smcircle) ///
>                 ylabel(, angle(horizontal) grid)   ytitle(Vote Share Conservatives)
{txt}  9{com}.         graph save    vsr_m_`var' , replace
{txt} 10{com}. {c )-}
{res}{txt}file {bf:vsr_b_x.gph} saved
{res}{txt}file {bf:vsr_s_x.gph} saved
{res}{txt}file {bf:vsr_g_x.gph} saved
{res}{txt}file {bf:vsr_m_x.gph} saved
{res}{txt}file {bf:vsr_b_y.gph} saved
{res}{txt}file {bf:vsr_s_y.gph} saved
{res}{txt}file {bf:vsr_g_y.gph} saved
{res}{txt}file {bf:vsr_m_y.gph} saved

{com}.  
. graph combine vsr_g_y.gph  vsr_g_x.gph  vsr_b_y.gph  vsr_b_x.gph ///
> vsr_s_y.gph  vsr_s_x.gph  vsr_m_y.gph  vsr_m_x.gph, ///
> col(2) xsize(18) ysize(20)  iscale(.6) scheme(s1mono)
{res}{txt}
{com}. graph save Figure_W4, replace
{res}{txt}file {bf:Figure_W4.gph} saved

{com}. 
. **Generate Figure W5
. preserve
{txt}
{com}. 
. foreach party in s m g b {c -(}
{txt}  2{com}.     matrix C =J(7,1,.) 
{txt}  3{com}.     local s=0
{txt}  4{com}.         foreach var  in  galtan_pct  education woman   {c -(}
{txt}  5{com}.                 local s=`s'+1
{txt}  6{com}.                 corr `var'  vsr_`party'
{txt}  7{com}.                 return list
{txt}  8{com}.                 matrix C[`s',1]=r(rho)
{txt}  9{com}.         {c )-}
{txt} 10{com}.         local s=`s'+1
{txt} 11{com}.         foreach var  in  cap_exec  sector stdoffshore_pct {c -(}
{txt} 12{com}.                 local s=`s'+1
{txt} 13{com}.                 corr `var'  vsr_`party'
{txt} 14{com}.                 return list
{txt} 15{com}.                 matrix C[`s',1]=r(rho)
{txt} 16{com}.         {c )-}
{txt} 17{com}.         svmat C
{txt} 18{com}.         sum C*
{txt} 19{com}.         ren C1 est_`party'
{txt} 20{com}. {c )-}
{txt}(obs=10,774)

             {c |} galtan~t    vsr_s
{hline 13}{c +}{hline 18}
  galtan_pct {c |}{res}   1.0000
       {txt}vsr_s {c |}{res}   0.0027   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.0027351010531129

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} educat~n    vsr_s
{hline 13}{c +}{hline 18}
   education {c |}{res}   1.0000
       {txt}vsr_s {c |}{res}  -0.2972   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.297186764152809

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |}    woman    vsr_s
{hline 13}{c +}{hline 18}
       woman {c |}{res}   1.0000
       {txt}vsr_s {c |}{res}  -0.0031   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.0031242179708122

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} cap_ex~t    vsr_s
{hline 13}{c +}{hline 18}
cap_exec_alt {c |}{res}   1.0000
       {txt}vsr_s {c |}{res}  -0.2629   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.2628867373802825

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |}   sector    vsr_s
{hline 13}{c +}{hline 18}
      sector {c |}{res}   1.0000
       {txt}vsr_s {c |}{res}  -0.0962   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.0961615718466797

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} stdoff~t    vsr_s
{hline 13}{c +}{hline 18}
stdoffshor~t {c |}{res}   1.0000
       {txt}vsr_s {c |}{res}  -0.1397   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.1397440309813829

{txt}matrices:
                  r(C) : {res} 2 x 2

{txt}    Variable {c |}        Obs        Mean    Std. dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 10}C1 {c |}{res}          6    -.132728    .1269029  -.2971868   .0027351
{txt}(obs=10,774)

             {c |} galtan~t    vsr_m
{hline 13}{c +}{hline 18}
  galtan_pct {c |}{res}   1.0000
       {txt}vsr_m {c |}{res}   0.0052   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.0051795848829115

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} educat~n    vsr_m
{hline 13}{c +}{hline 18}
   education {c |}{res}   1.0000
       {txt}vsr_m {c |}{res}   0.2753   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.2753058300094722

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |}    woman    vsr_m
{hline 13}{c +}{hline 18}
       woman {c |}{res}   1.0000
       {txt}vsr_m {c |}{res}   0.0006   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.0006027109493023

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} cap_ex~t    vsr_m
{hline 13}{c +}{hline 18}
cap_exec_alt {c |}{res}   1.0000
       {txt}vsr_m {c |}{res}   0.2445   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.2444752703154247

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |}   sector    vsr_m
{hline 13}{c +}{hline 18}
      sector {c |}{res}   1.0000
       {txt}vsr_m {c |}{res}   0.0916   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.0916454792298056

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} stdoff~t    vsr_m
{hline 13}{c +}{hline 18}
stdoffshor~t {c |}{res}   1.0000
       {txt}vsr_m {c |}{res}   0.1923   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.1922920434729691

{txt}matrices:
                  r(C) : {res} 2 x 2

{txt}    Variable {c |}        Obs        Mean    Std. dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 10}C1 {c |}{res}          6    .1349168    .1197902   .0006027   .2753058
{txt}(obs=10,774)

             {c |} galtan~t    vsr_g
{hline 13}{c +}{hline 18}
  galtan_pct {c |}{res}   1.0000
       {txt}vsr_g {c |}{res}   0.0666   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.0665600301707208

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} educat~n    vsr_g
{hline 13}{c +}{hline 18}
   education {c |}{res}   1.0000
       {txt}vsr_g {c |}{res}   0.3456   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.345577912248757

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |}    woman    vsr_g
{hline 13}{c +}{hline 18}
       woman {c |}{res}   1.0000
       {txt}vsr_g {c |}{res}   0.0179   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.0178541116841097

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} cap_ex~t    vsr_g
{hline 13}{c +}{hline 18}
cap_exec_alt {c |}{res}   1.0000
       {txt}vsr_g {c |}{res}  -0.0093   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.0093323536075483

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |}   sector    vsr_g
{hline 13}{c +}{hline 18}
      sector {c |}{res}   1.0000
       {txt}vsr_g {c |}{res}  -0.0551   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.0550878364192313

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} stdoff~t    vsr_g
{hline 13}{c +}{hline 18}
stdoffshor~t {c |}{res}   1.0000
       {txt}vsr_g {c |}{res}   0.1332   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.1331500760908356

{txt}matrices:
                  r(C) : {res} 2 x 2

{txt}    Variable {c |}        Obs        Mean    Std. dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 10}C1 {c |}{res}          6    .0831203    .1439235  -.0550878   .3455779
{txt}(obs=10,774)

             {c |} galtan~t    vsr_b
{hline 13}{c +}{hline 18}
  galtan_pct {c |}{res}   1.0000
       {txt}vsr_b {c |}{res}  -0.0634   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.06337181520179

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} educat~n    vsr_b
{hline 13}{c +}{hline 18}
   education {c |}{res}   1.0000
       {txt}vsr_b {c |}{res}  -0.1902   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.1901706265245245

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |}    woman    vsr_b
{hline 13}{c +}{hline 18}
       woman {c |}{res}   1.0000
       {txt}vsr_b {c |}{res}  -0.0322   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.0322448376900801

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} cap_ex~t    vsr_b
{hline 13}{c +}{hline 18}
cap_exec_alt {c |}{res}   1.0000
       {txt}vsr_b {c |}{res}  -0.0935   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.0934608381589759

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |}   sector    vsr_b
{hline 13}{c +}{hline 18}
      sector {c |}{res}   1.0000
       {txt}vsr_b {c |}{res}   0.0895   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}.0894999286531887

{txt}matrices:
                  r(C) : {res} 2 x 2
{txt}(obs=10,774)

             {c |} stdoff~t    vsr_b
{hline 13}{c +}{hline 18}
stdoffshor~t {c |}{res}   1.0000
       {txt}vsr_b {c |}{res}  -0.1131   1.0000


{txt}scalars:
                  r(N) =  {res}10774
                {txt}r(rho) =  {res}-.113059675296941

{txt}matrices:
                  r(C) : {res} 2 x 2

{txt}    Variable {c |}        Obs        Mean    Std. dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 10}C1 {c |}{res}          6   -.0671346    .0934943  -.1901706   .0894999
{txt}
{com}. 
. gen pos_1 =_n-.1 if est_s!=.
{txt}(10,768 missing values generated)

{com}. gen pos_2= pos_1+.2
{txt}(10,768 missing values generated)

{com}. 
. twoway (scatter est_b  pos_1 , msize(medlarge)  msymbol(circle)   mcolor(dkorange)) ///
>         (scatter est_g  pos_2 , msize(medlarge)  msymbol(lgx)   mcolor(forest_green)) ///
>         , ylabel(, angle(horizontal) grid) xline(4, lcolor(gs1) lpattern(dot))  ///
>         yline(0, lcolor(gs1) lpattern(dash))  ytitle(Correlation Coefficient)  ///
>         scale(1) ysize(15) xsize(20) scheme(s1mono) xscale(range(0.5 7.5))  ///
>         xtitle(Party, size(medium))  legend(order(1 "Sweden Democrats" 2 "Green Party")) ///
>         xlabel( 1 "Task Content" 2 "Education" 3  "Gender" 5 "Capital Ownership" 6 "Sector" 7 "Offshorability", labsize(medsmall) angle(horizontal))
{res}{txt}
{com}. graph save      sd_green_votescorr, replace
{res}{txt}file {bf:sd_green_votescorr.gph} saved

{com}. 
. 
. twoway (scatter est_m  pos_1 , msize(medlarge)  msymbol(circle)   mcolor(navy)) ///
>         (scatter est_s  pos_2 , msize(medlarge)  msymbol(lgx)   mcolor(cranberry)) ///
>         , ylabel(,angle(horizontal) grid) xline(4, lcolor(gs1) lpattern(dot)) ///
>         yline(0, lcolor(gs1) lpattern(dash))  ytitle(Correlation Coefficient)  ///
>         scale(1) ysize(15) xsize(20) scheme(s1mono) xscale(range(0.5 7.5))  xtitle(Party, size(medium))  ///
>         legend(order(1 "Conservatives" 2 "Social Democrats")) ///
>         xlabel( 1 "Task Content" 2 "Education" 3  "Gender" 5 "Capital Ownership" 6 "Sector" 7 "Offshorability", labsize(medsmall) angle(horizontal))
{res}{txt}
{com}. graph save      cons_soc_votescorr, replace
{res}{txt}file {bf:cons_soc_votescorr.gph} saved

{com}. 
. restore
{txt}
{com}. graph combine sd_green_votescorr.gph    cons_soc_votescorr.gph , col(2) iscale(1)       scheme(s1mono)   ysize(8) xsize(20)     ycommon
{res}{txt}
{com}. graph save Figure_W5, replace
{res}{txt}file {bf:Figure_W5.gph} saved

{com}. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}\\micro.intra\Projekt\P0624$\P0624_Gem\Kitschelt\submission\precinct_vote.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}16 Jan 2024, 11:36:10
{txt}{.-}
{smcl}
{txt}{sf}{ul off}